package org.example.mallchat.domain.enums;

import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * Description: 拉黑类型枚举
 * Author: <a href="https://github.com/zongzibinbin">abin</a>
 * Date: 2023-03-19
 */
@AllArgsConstructor
@Getter
public enum BlackEnum {
    IP(1, "ip"),
    UID(2, "uid"),
    DEVICE(3, "device"),;

    private final Integer id;
    private final String desc;

    private static Map<Integer, BlackEnum> cache;

    static {
        cache = Arrays.stream(BlackEnum.values()).collect(Collectors.toMap(BlackEnum::getId, Function.identity()));
    }

    public static BlackEnum of(Long type) {
        return cache.get(type);
    }
}
